<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "{{%menu}}".
 *
 * @property int $id
 * @property int $module_id 模块id
 * @property string $route_name 路由名
 * @property string $route 路由
 * @property int $sort 排序
 * @property int $is_show 1 显示 2隐藏
 * @property int $create_time 添加时间
 */
class Menu extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%menu}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['module_id', 'route_name', 'route', 'sort'], 'required'],
            [['module_id', 'sort', 'create_time','is_show'], 'integer'],
            [['route_name','create_user'], 'string', 'max' => 20],
            [['route'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'module_id' => '模块id',
            'route_name' => '路由名',
            'route' => '路由',
            'sort' => '排序',
            'is_show' => '1 显示 2隐藏',
            'create_time' => '添加时间',
        ];
    }

    /**
     * 关联路由
     */
    public function getRoute()
    {
        return $this->hasMany(Route::className(),['menu_id'=>'id']);
    }


}
